package com.spring.pojo;

/**
 * 通过此对象封装服务端向客户端响应的数据
 * @author 黄嘉强
 */
public class JsonResult {

    /**响应状态（0表示error，1表示ok......）*/
    private Integer state;
    /**响应消息（update ok, delete ok.....）*/
    private String message = "ok";
    /**具体的业务数据（比如查询结果）*/
    private Object data;

    public JsonResult(){}
    public JsonResult(String message){
        this.message = message;
    }
    public JsonResult(Object data){
        this.data = data;
    }
    public JsonResult(Throwable e){
        this.state = 0;
        this.message = e.getMessage();
    }


    @Override
    public String toString() {
        return "JsonResult{" +
                "state=" + state +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
